package qldc.pm.qlktcsdldc.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import qldc.pm.qlktcsdldc.model.DanhMucSoBanNganh;
import qldc.pm.qlktcsdldc.service.base.DanhMucSoBanNganhLocalServiceBaseImpl;
import qldc.pm.qlktcsdldc.utils.FLog;

import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.model.User;

/**
 * The implementation of the danh muc so ban nganh local service.
 *
 * <p>
 * All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy their definitions into the {@link qldc.pm.qlktcsdldc.service.DanhMucSoBanNganhLocalService} interface.
 *
 * <p>
 * This is a local service. Methods of this service will not have security checks based on the propagated JAAS credentials because this service can only be accessed from within the same VM.
 * </p>
 *
 * @author Brian Wing Shun Chan
 * @see qldc.pm.qlktcsdldc.service.base.DanhMucSoBanNganhLocalServiceBaseImpl
 * @see qldc.pm.qlktcsdldc.service.DanhMucSoBanNganhLocalServiceUtil
 */
public class DanhMucSoBanNganhLocalServiceImpl
    extends DanhMucSoBanNganhLocalServiceBaseImpl {
    /*
     * NOTE FOR DEVELOPERS:
     *
     * Never reference this interface directly. Always use {@link qldc.pm.qlktcsdldc.service.DanhMucSoBanNganhLocalServiceUtil} to access the danh muc so ban nganh local service.
     */
	
	public DanhMucSoBanNganh addDanhMucSoBanNganh( String tenSoBanNghanh, String diaChi, String sDT, String fax, String email, String website, String nguoiLienHe, User user)
			throws PortalException, SystemException {
		long DanhMucSoBanNganhId = counterLocalService.increment(DanhMucSoBanNganh.class.getName());

		// create a new instance of DanhMucSoBanNganh without saving it to the database
		DanhMucSoBanNganh DanhMucSoBanNganh = createDanhMucSoBanNganh(DanhMucSoBanNganhId);

		// set audit fields
		DanhMucSoBanNganh.setGroupId(user.getGroupId());
		DanhMucSoBanNganh.setCompanyId(user.getCompanyId());
		DanhMucSoBanNganh.setUserId(user.getUserId());
		DanhMucSoBanNganh.setUserName(user.getScreenName());
		DanhMucSoBanNganh.setCreateDate(new Date());

		// set other fields
		DanhMucSoBanNganh.setTenSoBanNganh(tenSoBanNghanh);
		DanhMucSoBanNganh.setDiaChi(diaChi);
		DanhMucSoBanNganh.setSoDienThoai(sDT);
		DanhMucSoBanNganh.setFax(fax);
		DanhMucSoBanNganh.setEmail(email);
		DanhMucSoBanNganh.setWebsite(website);
		DanhMucSoBanNganh.setNguoiLienHe(nguoiLienHe);
		DanhMucSoBanNganh.setDeleted(false);

		// save DanhMucSoBanNganh into the database
		return addDanhMucSoBanNganh(DanhMucSoBanNganh);
	}

	public DanhMucSoBanNganh updateDanhMucSoBanNganh(
		long DanhMucSoBanNganhId, String tenSoBanNghanh, String diaChi, String sDT, String fax, String email, String website, String nguoiLienHe, User user)
		throws PortalException, SystemException {

		// get the DanhMucSoBanNganh with the given DanhMucSoBanNganhId
		DanhMucSoBanNganh DanhMucSoBanNganh = getDanhMucSoBanNganh(DanhMucSoBanNganhId);

		// set audit fields
		DanhMucSoBanNganh.setGroupId(user.getGroupId());
		DanhMucSoBanNganh.setCompanyId(user.getCompanyId());
		DanhMucSoBanNganh.setUserId(user.getUserId());
		DanhMucSoBanNganh.setUserName(user.getScreenName());
		DanhMucSoBanNganh.setModifiedDate(new Date());

		// set other fields
		DanhMucSoBanNganh.setTenSoBanNganh(tenSoBanNghanh);
		DanhMucSoBanNganh.setDiaChi(diaChi);
		DanhMucSoBanNganh.setSoDienThoai(sDT);
		DanhMucSoBanNganh.setFax(fax);
		DanhMucSoBanNganh.setEmail(email);
		DanhMucSoBanNganh.setWebsite(website);
		DanhMucSoBanNganh.setNguoiLienHe(nguoiLienHe);
		DanhMucSoBanNganh.setDeleted(false);
		// update the DanhMucSoBanNganh after set all needed parameters in to the
		// database
		return updateDanhMucSoBanNganh(DanhMucSoBanNganh);
	}
	
	public DanhMucSoBanNganh deteleDanhMucSoBanNganh(long DanhMucSoBanNganhId, User user)
			throws PortalException, SystemException {

			// get the DanhMucSoBanNganh with the given DanhMucSoBanNganhId
			DanhMucSoBanNganh DanhMucSoBanNganh = getDanhMucSoBanNganh(DanhMucSoBanNganhId);

			// set audit fields
			DanhMucSoBanNganh.setGroupId(user.getGroupId());
			DanhMucSoBanNganh.setCompanyId(user.getCompanyId());
			DanhMucSoBanNganh.setUserId(user.getUserId());
			DanhMucSoBanNganh.setUserName(user.getScreenName());
			DanhMucSoBanNganh.setModifiedDate(new Date());

			// set other fields
			DanhMucSoBanNganh.setDeleted(true);
			// update the DanhMucSoBanNganh after set all needed parameters in to the
			// database
			return updateDanhMucSoBanNganh(DanhMucSoBanNganh);
		}
	public List<DanhMucSoBanNganh> searchByTenSoBanNganh( String tenSoBanNganh)throws SystemException {
		return danhMucSoBanNganhFinder.searchByTenSoBanNganh(tenSoBanNganh );
	}
	
	public List<DanhMucSoBanNganh> searchAll()throws SystemException {
		return danhMucSoBanNganhFinder.searchAll( );
	}
}
